﻿@namespace BootstrapBlazor.Components
@inherits PopConfirmButtonBase

@if (_renderTooltip)
{
    <Tooltip Title="@TooltipText" Placement="TooltipPlacement" Trigger="@TooltipTrigger">
        @RenderComponent
    </Tooltip>
}
else
{
    @RenderComponent
}

@code {
    RenderFragment RenderComponent =>
    @<DynamicElement TagName="@TagName" OnClick="Show" id="@Id"
                     class="@ClassString" role="dialog" tabindex="@Tab" data-bb-confirm="@ConfirmString"
                     data-bb-close="@TriggerCloseString"
                     data-bs-custom-class="@CustomClassString" data-bs-trigger="@TriggerString" data-bs-placement="@PlacementString">
        @if(IsAsyncLoading)
        {
            <i class="@LoadingIcon"></i>
        }
        else if (!string.IsNullOrEmpty(Icon))
        {
            <i class="@Icon"></i>
        }
        @if (!string.IsNullOrEmpty(Text))
        {
            <span>@Text</span>
        }
        <CascadingValue Value="this" IsFixed="true">
            @ChildContent
        </CascadingValue>
        <PopConfirmButtonContent Title="@Title" Content="@Content" Icon="@ConfirmIcon"
                                 CloseButtonColor="@CloseButtonColor" CloseButtonText="@CloseButtonText" CloseButtonIcon="@CloseButtonIcon"
                                 ConfirmButtonColor="@ConfirmButtonColor" ConfirmButtonText="@ConfirmButtonText" ConfirmButtonIcon="@ConfirmButtonIcon"
                                 ShowCloseButton="@ShowCloseButton" OnClose="@OnClose"
                                 ShowConfirmButton="@ShowConfirmButton" OnConfirm="@OnClickConfirm" ChildContent="@BodyTemplate" />
    </DynamicElement>;
}
